/* eslint-disable eqeqeq *///忽略==的警告
import { saveLightInfor, saveGroupSetInfor, saveAreaInfor } from './homeUtils'
import { isRGBDeviceset, isDimDeviceset, allAreaGetTempRange, allSubgroupGetTempRange, getTempRange } from './pidUtils'
import { getOctets2Msg } from './dataUtils'
import { homeDeng } from "../api/index"
import PubSub from 'pubsub-js'
import { meshLog, SPRemove, SPGet, SPSet } from '../config'
import { isLightDevice } from './pidUtils';
//添加新的属性的时候来修改数据结构的时候只需要修改这个地方的数据结构就好了
export const createNewDateThree = (mAreaSet, mGroupSet, mDeviceSet) => {
    //从新组建一个新的groupSet
    let groupSetx = []
    mGroupSet.map((item, key) => {
        groupSetx[key] = {
            name: item.name, areaNo: item.areaNo, groupNo: item.groupNo,
            minTrim: item.minTrim, maxTrim: item.maxTrim, isOnoff: '00', dim: '19661', tem: '2700',
            isrgb: '0', rgbH: '0', rgbS: '0', rgbL: '0', isOnline: '00', isdimdeng: '00'
        }
    })
    //meshLog("adminUtils.js,30 新建之后放在localStorage的groupSetx", groupSetx);
    SPSet('groupSetx', JSON.stringify(groupSetx))//存到localStorage
    //从新组建一个新的deviceSet
    let deviceSetx = []
    mDeviceSet.map((item, key) => {
        let isrgb = isRGBDeviceset(item.pid)
        let isdimdeng = isDimDeviceset(item.pid)
        deviceSetx[key] = {
            address: item.address, areaNo: item.areaNo, mac: item.mac,
            maxPower: item.maxPower, maxTrim: item.maxTrim,
            minTrim: item.minTrim, pid: item.pid, powerIndex: item.powerIndex, groupNo: item.groupNo,
            tempIndex: item.tempIndex, vid: item.vid, isOnoff: '00', dim: '19661', tem: '2700',
            isrgb: isrgb, rgbH: '0', rgbS: '0', rgbL: '0', isOnline: '00', isdimdeng: isdimdeng, 'lightID': item.lightID
        }
    })
    // meshLog("adminUtils.js 45,新建之后放在localStorage的deviceSetx", deviceSetx);
    SPSet('deviceSetx', JSON.stringify(deviceSetx))//存到localStorage
}
//修改deviceSetx的数据结构，主要是为了mqtt单发获取灯的数据来
export const mqttdeviceset = () => {
    let deviceSetx = JSON.parse(SPGet("deviceSetx"));
    let devisUnOnline = deviceSetx.filter((item) => {
        if ((item.isOnline == '00') && isLightDevice(item.pid)) {
            return item
        }
    })
    meshLog('adminUtils.js,57行 原本devisUnOnline', devisUnOnline);
    let areaSetx = JSON.parse(SPGet("areaSetx"));
    let devmqttdate = []
    let zhonghe = []
    if (areaSetx.length > 0) {
        meshLog('adminUtils.js,61行 有组信息，需要通过组来判断',);
        for (let i = 0; i < areaSetx.length; i++) {
            devmqttdate[i] = []
        }
        meshLog('adminUtils.jsx,67行 每个组中的灯', devmqttdate);
        let mqttUngroupdate = []
        meshLog('adminUtils.jsx,67行 所有Ungroup的灯', mqttUngroupdate);
        let fengdate = []
        let zhonghedate1 = []
        let zhonghedate2 = []
        for (let b = 0; b < devmqttdate.length; b++) {
            fengdate[(2) * b] = devmqttdate[b].slice(0, Math.round(devmqttdate[b].length) * 0.3);
            zhonghedate1 = zhonghedate1.concat(fengdate[(2) * b])
            fengdate[(2) * b + 1] = devmqttdate[b].slice(Math.round(devmqttdate[b].length) * 0.3, (devmqttdate[b].length));
            zhonghedate2 = zhonghedate2.concat(fengdate[(2) * b + 1])
        }
        zhonghe = zhonghedate1.concat(mqttUngroupdate, zhonghedate2)
        // meshLog('zhonghedate1', zhonghedate1);
        // meshLog('zhonghedate1', zhonghedate2);
        meshLog('adminUtils.js 80 ,整合之后所有的灯', zhonghe);
    } else {
        zhonghe = deviceSetx.filter((item) => {
            if ((item.isOnline == '00') && isLightDevice(item.pid)) {
                return item
            }
        })
    }

    return zhonghe
}
//mqtt数据返回的处理方法
export const mqtthHndleDate = (devSetItem) => {
    //修改数据库发一系列操作些列方法
    meshLog('mqtt处理调用方式',);

}
